// page_other/zdysqy/zdysqy.js
let app = getApp()
let yuming = app.globalData.yuming
let shuzong = [];
let shu = [];
const request = require('../../config/request');
Page({
  ...request,
  /**
   * 页面的初始数据
   */
  data: {
    yuming: yuming,
    heights: "",
    title: "执业药师",
    page: 1,
    gongwu: false,
    shopName: '',
    list: [],
    isShow: false,
    posterWidth: 250,
    posterHeight: 400,
    qrSize: 200,
    qrCode: '',
    maskFlag: true,
    zhidian_id: '',
    shopstaff__Name: '',
    startime: '请选择',
    startimes: '',
    endtime: '请选择',
    endtimes: '',
    top_hei: '',
    contents_hei: '',
    chu_total:''
  },
  // 放大
  fangda(e) {
    var img = e.currentTarget.dataset.img
    var list = e.currentTarget.dataset.list
    var arr = []
    for (let i in list) {
      arr.push(list[i]); //属性
    }
    wx.previewImage({
      current: img,
      urls: arr
    })
  },
  // 开始
  bindDateChange(e) {
    this.setData({
      startime: e.detail.value,
      startimes: e.detail.value,
      pagefen_index: 3,
      page: 1
    })
    this.getysdklist()
  },
  // 结束
  bindDateChanges(e) {
    if (e.detail.value < this.data.startime) {
      wx.showToast({
        title: '不能小于开始时间!',
        icon: 'error'
      })
    } else {
      this.setData({
        endtime: e.detail.value,
        endtimes: e.detail.value,
        pagefen_index: 3,
        page: 1
      })
      this.getysdklist()
    }
  },
  scewm() {
    wx.showLoading({
      title: '生成中',
      icon: 'none'
    })
    this.setData({
      isShow: true
    })
    this.myRequest(yuming + 'Besall/fromAppletQrimg', {
      scene: wx.getStorageSync('shopId'),
      page: 'page_other/zdysdk/zdysdk',
      from: 'EabEnd',
      shopId: wx.getStorageSync('shopId')
    }, 'POST').then(res => {
      wx.hideLoading();
      console.log(res);
      this.setData({
        qrCode: res.data.data
      })
      console.log(this.data.qrCode)
    })
  },
  getysdklist() {
    let that = this;
    wx.showLoading({
      title: '加载中',
      icon: 'none'
    })
    this.myRequest(yuming + 'shop/shop_staff_yaoshi_signlist', {
      shopId: wx.getStorageSync('shopId'),
      page: that.data.page,
      staffid: that.data.zhidian_id,
      startime: that.data.startimes,
      endtime: that.data.endtimes
    }, 'POST').then(res => {
      this.setData({
        chu_total: res.data.total
    })
      wx.hideLoading();
      shu = res.data.data
      shu.forEach(item => {
        let arr = item.createtime.split(/\s+/);
        item.time = arr[1]
      })
      if (that.data.page != 1) {
        if (shu.length != 10) {
          wx.showToast({
            title: '没有更多数据了~',
            icon: "none"
          })
          that.setData({
            gongwu: true
          })
        }
      }
      this.setData({
        list: shuzong.concat(shu)
      })
    })
  },
  backs() {
    wx.navigateBack({
      delta: 0
    })
  },
  guanbi() {
    this.setData({
      isShow: false,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      heights: wx.getMenuButtonBoundingClientRect().top + 5,
      title: options.title,
      shopName: wx.getStorageSync('shopname'),
      zhidian_id: options.id,
      shopstaff__Name: options.shopstaff__Name,
      top_hei: wx.getMenuButtonBoundingClientRect().top + 50,
      contents_hei: wx.getMenuButtonBoundingClientRect().top + 120,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getysdklist()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },
})